package com.smart_environmental_protection.controller;

import com.smart_environmental_protection.pojo.Order;
import com.smart_environmental_protection.pojo.Point;
import com.smart_environmental_protection.service.PointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class PointController {
    @Autowired
    private PointService pointService;

    @GetMapping("/system/reward/list")
    public Map<String,Object> POINT_LIST(){
        Map map=new HashMap<String,Object>();
        List<Point> points=pointService.POINT_LIST();
        if ((points!=null)&& points.size()!=0){
            map.put("success",true);
            map.put("msg","成功");
            map.put("code",200);
            map.put("rows",points);
        }else {
            map.put("success",false);
            map.put("msg","失败");
        }
        return map;
    }


    @GetMapping("/system/reward/{id}")
    public Map<String,Object> Points(@PathVariable Integer id){
        Map map=new HashMap<String,Object>();
        Point poin=pointService.Points(id);
        if ((poin!=null)){
            map.put("success",true);
            map.put("msg","成功");
            map.put("code",200);
            map.put("rows",poin);
        }else {
            map.put("success",false);
            map.put("msg","失败");
        }
        return map;
    }

}
